<?php

class CronController extends Controller
{
	public function actionIndex()
	{
		$cams = Yii::app()->params['cams'];
		foreach ($cams as $i => $cam ) {
                	$cs = New WebcamImage();
                	$cs->datetime=date('Y-m-d H:i:s');
                	$cs->device_id = $cam['id'];
                	$cs->save();
                	$path = Yii::app()->basePath .'/../';
                	$cmd = 'sudo /usr/bin/streamer -c /dev/video0 -b 16 -j 75 -s 640x480 -o ' . $path . 'images/' . $cam['id'] . '/snapshot_' . $cs->id . '.jpeg  2>&1';
                	$out = shell_exec($cmd);
		}
	}

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}
